<?php
class LoadJsonAction extends Action {
	
	/**
	 *
	 * @author think-yuan
	 *         @
	 *         从数据库中查找到所有的管线信息，然后输出为JSON
	 */
	public function loadLines() {
		$array1 = array (
				'lineNum',
				'name' 
		);
		$array2 = array (
				" ",
				" " 
		);
		$array3 = array ();
		
		/*
		 * 此处查询数据库得到所有的管线信息
		 */
		
		// 将所有的管线信息放入数组$array3中
		for($i = 1; $i <= 2; $i ++) {
			$array2 [0] = $i;
			$array2 [1] = $i . "号燃气管线";
			$arrtmp = array_combine ( $array1, $array2 );
			array_push ( $array3, $arrtmp );
		}
		for($i = 3; $i <= 4; $i ++) {
			$array2 [0] = $i;
			$array2 [1] = $i . "号压缩空气管线";
			$arrtmp = array_combine ( $array1, $array2 );
			array_push ( $array3, $arrtmp );
		}
		
		$arrayLines = array (
				'lines' => $array3 
		);
		
		echo json_encode ( $arrayLines );
	}
	public function loadPointsByLine() {
		$arr3 = array (
				'code',
				'name',
				'lon',
				'lat' 
		);
		$arr4 = array (
				" ",
				" ",
				" ",
				" " 
		);
		$arr5 = array ();
		for($i = 1; $i <= 4; $i ++) {
			$arr4 [0] = $i;
			$arr4 [1] = $i . "号点";
			$arr4 [2] = "114.265709";
			$arr4 [3] = "30.439554";
			$arrtmp = array_combine ( $arr3, $arr4 );
			array_push ( $arr5, $arrtmp );
		}
		$arr2 = array (
				'lineNum' => '1',
				'points' => $arr5 
		);
		echo json_encode ( $arr2 );
	}
}